<?php


namespace App\Traits\Controllers;

use Illuminate\Http\Request;
use Illuminate\Validation\ValidationException;

trait StoreTraits
{

    /**
     * 保存
     *
     * @param Request $request
     * @return \Dingo\Api\Http\Response
     * @throws ValidationException
     */
    public function store(Request $request)
    {
        $this->validateData($request);
        // 保存创建人
        $request->offsetSet('system_admin_id', $this->admin_user('id'));
        $model = $this->getQuery()->fill($request->all());
        $model->save();
        return $this->response->created();
    }

}
